﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace kehuguanli.Common
{
    public class SetMes
    {
        public static void CreatCookies(string cookieName, int time, string strValue, string strDomain)
        {
            HttpCookie aCookie;
            aCookie = new HttpCookie(cookieName);
            aCookie.Value = HttpContext.Current.Server.HtmlEncode(strValue);
            aCookie.Expires = DateTime.Now.AddHours(time);
            if (!string.IsNullOrEmpty(strDomain))
            {
                aCookie.Domain = strDomain;
            }
            HttpContext.Current.Response.Cookies.Add(aCookie);
        }
        public static void SetSession(string strKey, string strValue)
        {
            HttpContext.Current.Session[strKey] = strValue;
        }
        public static void RemoveSession(string strKey)
        {
            HttpContext.Current.Session.Remove(strKey);
        }
        /// <summary>
        /// 删除所有会话
        /// </summary>
        /// <param name="strKey"></param>
        public static void RemoveAllSession()
        {
            HttpContext.Current.Session.RemoveAll();
        }
    }
}